<!DOCTYPE html>
<html>

<head>
  <meta charset="UTF-8" />
  <title>03_一秒后加1</title>
  <!-- 引入Vue -->
  <script type="text/javascript" src="../js/vue.js"></script>
</head>

<body>
  <!-- 准备好一个容器-->
  <div id="demo">
    <h1>数组加1:{{num}}</h1>
    <button @click="onchange()">点击加</button>
  </div>
</body>

<script type="text/javascript">
  //阻止 vue 在启动时生成生产提示。
  Vue.config.productionTip = false;
  new Vue({
    el: '#demo',
    data() {
      return {
        num: 1
      }
    },
    methods: {
      onchange() {
        setTimeout(() => { this.num = this.num + 1 }
          , 1000)

      }
    },
  })



</script>

</html>